<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
<TITLE>BLOBs for PHPLIB: BLOB (Binary Large OBjects)</TITLE>

<LINK HREF="blob.html#toc1" REL=contents>
</HEAD>
<BODY>
Next Previous
<A HREF="blob.html#toc1">Contents</A>
<HR>
<H2><A NAME="s1">1.</A> <A HREF="blob.html#toc1">BLOB (Binary
Large OBjects)</A></H2>

<P>This chapter is intended to give you a quick introduction to
BLOBs, their interface as proposed for PHPLIB.</P>

<H2><A NAME="ss1.1">1.1</A> <A HREF="blob.html#toc1.1">Defining
the problem</A></H2>

<P>Achieving the goal of creating portable applications is hindered
by the fact that no portable way of storing large amount of data exists.</P>
<P>Every database vendor defines his own application programming
interface (API) to access binary large objects, or uses other,
non-standard ways to enable the use of BLOBs.</P>
<P>Enhancing the existing vendor neutral support for databases in
PHPLIB to also include BLOB support could be a short-term solution to
the problem.</P>

<H2><A NAME="ss1.2">1.2</A> <A HREF="blob.html#toc1.2">Proposed
extension API</A></H2>


<P>An overview over the function calls follows.</P>
<P>
<DL>
	<DT><B>blob_create()</B>
	<DD>
	<P>This will create a new BLOB and return its ID. If it is
	impossible to create a new BLOB, this function will <CODE>halt()</CODE>
	the execution and generate an error message.</P>

	<DT><B>blob_open($ID)</B>
	<DD>
	<P>Opens the specified BLOB for reading and writing and returns
	true or false on success or failure, respectively.</P>

	<DT><B>blob_close($ID)</B>
	<DD>
	<P>Closes the referenced BLOB. Do not forget this - it might be
	necessary for some databases or you might face data loss.</P>

	<DT><B>blob_delete($ID)</B>
	<DD>
	<P>Deletes the specified BLOB. All associated resources are freed.
	The BLOB must not be referenced at a later time.</P>

	<DT><B>blob_read($ID)</B>
	<DD>
	<P>Reads the entire data of BLOB and returns it.</P>

	<DT><B>blob_write($ID, $DATA)</B>
	<DD>
	<P>Overwrites the whole BLOB with $DATA.</P>
</DL>
</P>

<H2><A NAME="ss1.3">1.3</A> <A HREF="blob.html#toc1.3">Design
notes</A></H2>

<P>The goal was to create a vendor neutral API which could be
implemented easily with most databases. Eventually, it should provide a
"fallback" mode enabling the user to utilize BLOBs even if the database
does not support BLOBs natively. Keep in mind that it should be able to
cover as many databases as possible and therefore only implements a
subset of functionality provided by modern databases.</P>

<HR>
Next Previous
<A HREF="blob.html#toc1">Contents</A>
</BODY>
</HTML>
